5.5. Suppose that on the amazing Bleeblon computer, variables with type float can store three decimal digits. Also suppose that the Bleeblon's floating point registers can store four decimal digits, and that after any floating point operation, the result is rounded to three decimal digits before being stored. Now suppose a C program declares an array a as follows:
float a[] = f4.0, 3.0, 3.0, 1000.0g;
a. What is the output of the following block of code if it's run on the
Bleeblon?
int i;
float sum = 0.0;
for (i = 0; i < 4; i++)
sum += a[i];
printf("sum = %4.1fnn", sum);
b. Now consider the following code:
int i;
float sum = 0.0;
# pragma omp parallel for num threads(2) n
reduction(+:sum)
for (i = 0; i < 4; i++)
sum += a[i];
printf("sum = %4.1fnn", sum);
Suppose that the run-time system assigns iterations i = 0, 1 to thread 0 and i = 2, 3 to thread 1. What is the output of this code on the Bleeblon?
 
 
View Solution
 
 
 
<< Back Next >>